﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.Common;
using DataAccess;

public partial class Result : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        int TotalMark = 0;
        DbCommand cmd = GenericData.CreateCommand();
        cmd.CommandText = "SELECT SUM(Mark) FROM ExamQuestion LEFT JOIN CandidateQuestionAnswer ON ExamQuestion.ID = CandidateQuestionAnswer.ExamQuestionID LEFT JOIN Question ON Question.ID = ExamQuestion.QuestionID WHERE ExamQuestion.ExamID = " + Session["Exam"].ToString();
        TotalMark = Int32.Parse(GenericData.ExecuteScalar(cmd));

        if (Session["Username"] == null)
        {
            Response.Redirect("Default.aspx");
        }
        else
        {
            txtFullname.Text = Session["Fullname"].ToString();
            txtEmail.Text = Session["Email"].ToString();
            txtPhone.Text = Session["Mobile"].ToString();
            txtAddress.Text = Session["Address"].ToString();

            lblMark.Text = Session["CountAnserTrue"].ToString();

            double Result = (Int32.Parse(Session["CountAnserTrue"].ToString()) * 100) / 15;
            if (Result >= 60)
            {
                lblResult.CssClass = "success";
                lblResult.Text = "PASSED";
            }
            else
            {
                lblResult.CssClass = "unsucess";
                lblResult.Text = "FAILED";
            }

        }
    }
}